package fojta;

import java.io.*;

public class MainTester {

	public static void main(String args[]) {
		pocitani_s_odpory();
		// testerResistorPoint();
		// testerResistorMatrix();
	}
	
	@SuppressWarnings("unused")
	private static void testerResistorMatrix() {
		ResistorMatrix M = new ResistorMatrix(3);
		// M.print();
		
		ResistorPoint A = M.getPoint(0, 0);
		
		for( ResistorPoint col = A;
			col != null; col = col.getDown()
		) {
			for( ResistorPoint row = col;
				row != null; row = row.getRight()
			) {
				row.print();
				System.out.print("\t");
			}
			System.out.println();
		}
	}
	
	@SuppressWarnings("unused")
	private static void testerResistorPoint() {
		/*
		 * System.out.println("Hello world"); System.out.println("Zadej cele
		 * cislo: "); int i = ctiInt(); System.out.println("i = " + i);
		 */
		ResistorPoint A = new ResistorPoint();
		A.makeDown();
		ResistorPoint B = A.getDown();
		B.makeLeft();
		B.getLeft().makeUp();
		
		// create circle
		B.getLeft().getUp().setRight(B.getUp());

		System.out.println("Point A = " + A);
		System.out.println("Point B = " + B);

		for (int i = 0; i < 2; i++) {
			B = B.getLeft();
			System.out.println("Point B = " + B);

			B = B.getUp();
			System.out.println("Point B = " + B);

			B = B.getRight();
			System.out.println("Point B = " + B);

			B = B.getDown();
			System.out.println("Point B = " + B);
		}

		A = null;
		B = null;

		System.out.println("Printing all points");
		ResistorPoint.printlnAll();
		System.out.println("Clearing all points");
		ResistorPoint.clearAll();
		System.out.println("Printing all points");
		ResistorPoint.printlnAll();
	}
	
	/**
	 * Precte pole bytu a prevede na cislici
	 * 
	 * @return 0, pokud neuspeje
	 */
	public static int ctiInt() {
		byte [] pole = new byte[20];
		String nacteno = "";
		int i;
		
		try {
			// precte pole bytu
			System.in.read(pole);
			// prevede do stringu
			nacteno = new String(pole).trim();
			// prevede ze stringu do intu
			i = Integer.valueOf(nacteno).intValue();
			return i;
		}
		catch(IOException e)
		{
			System.out.println("Chybne nactene cislo !");
			return 0;
		}
		catch(NumberFormatException e)
		{
			System.out.println("Spatny format cisla " + nacteno);
			return 0;
		}
	}

	@SuppressWarnings("unused")
	private static void pocitani_s_odpory() {
		// jsou dva typy odporu
		// paralelni
		// seriove zapojeni
		// a trojuhelnik
		
		// dva body jsou v siti klicove
		/*
		 * Jsou to poly + a -
		 * Mezi nimi se meri odpor
		 */
				
		/*
		 * Otazka je, jak najdu cestu z plus do minus a spocitam odpory
		 */
		
		CalculateResistance calc = new CalculateResistance(10);
		
		System.out.println( "Odpor je " + calc.calculate() );
	}
}
